using System;
using System.ComponentModel.DataAnnotations;
using ThuySan.Bussiness;

namespace ThuySan.Models
{
	[Serializable]
	public partial class CategoryModel 
	{

		#region Constructor

		public CategoryModel()
		{
		}

		public CategoryModel(Category value)
		{
			CategoryId = value.CategoryId;
			Name = value.Name;
			Description = value.Description;
			Detail = value.Detail;
			PageUrl = value.PageUrl;
			IsCategoryMenu = value.IsCategoryMenu;
			Priority = value.Priority;
		}

		#endregion

		#region Fields

		private System.Int32 _CategoryId;

		private System.String _Name;

		private System.String _Description;

		private System.String _Detail;

		private System.String _PageUrl;

		private System.Boolean _IsCategoryMenu;

		private System.Int32? _Priority;

		#endregion

		#region Properties

		//[NotChanged]
		//[Required(ErrorMessage = "Value is required")]
		//[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
		//[StringLength(0)]
		//[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
		public System.Int32 CategoryId
		{
			get
			{
				return _CategoryId;
			}
			set
			{
				_CategoryId = value;
			}
		}

		//[NotChanged]
        [Required(ErrorMessage = "Value is required")]
		//[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
		//[StringLength(0)]
		//[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
		public System.String Name
		{
			get
			{
				return _Name;
			}
			set
			{
				_Name = value;
			}
		}

		//[NotChanged]
		//[Required(ErrorMessage = "Value is required")]
		//[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
		//[StringLength(0)]
		//[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
		public System.String Description
		{
			get
			{
				return _Description;
			}
			set
			{
				_Description = value;
			}
		}

		//[NotChanged]
		//[Required(ErrorMessage = "Value is required")]
		//[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
		//[StringLength(0)]
		//[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
		public System.String Detail
		{
			get
			{
				return _Detail;
			}
			set
			{
				_Detail = value;
			}
		}

		//[NotChanged]
		//[Required(ErrorMessage = "Value is required")]
		//[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
		//[StringLength(0)]
		//[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
		public System.String PageUrl
		{
			get
			{
				return _PageUrl;
			}
			set
			{
				_PageUrl = value;
			}
		}

		//[NotChanged]
		//[Required(ErrorMessage = "Value is required")]
		//[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
		//[StringLength(0)]
		//[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
		public System.Boolean IsCategoryMenu
		{
			get
			{
				return _IsCategoryMenu;
			}
			set
			{
				_IsCategoryMenu = value;
			}
		}

		//[NotChanged]
		//[Required(ErrorMessage = "Value is required")]
		//[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
		//[StringLength(0)]
		//[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
		public System.Int32? Priority
		{
			get
			{
				return _Priority;
			}
			set
			{
				_Priority = value;
			}
		}

		#endregion

		#region Operators

		public void Update(Category value)
		{
            //value.CategoryId = CategoryId;
			value.Name = Name;
			value.Description = Description;
			value.Detail = Detail;
			value.PageUrl = PageUrl;
			value.IsCategoryMenu = IsCategoryMenu;
			value.Priority = Priority;
		}

		public static implicit operator CategoryModel(Category obj)
		{
			return new CategoryModel(obj);
		}

		public static implicit operator Category(CategoryModel obj)
		{
			Category value = new Category();
			obj.Update(value);
			return value;
		}

		#endregion

	}
}
